# -*- mode: python -*-

Import("env")

env.Library(
    target='metadata',
    source=[
        'operation_shard_version.cpp',
        'collection_metadata.cpp',
        'metadata_loader.cpp',
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/base',
        '$BUILD_DIR/mongo/db/common',
        '$BUILD_DIR/mongo/db/range_arithmetic',
        '$BUILD_DIR/mongo/s/catalog/catalog_types',
        '$BUILD_DIR/mongo/s/common',
        '$BUILD_DIR/mongo/db/service_context',
    ]
)

env.Library(
    target='migration_types',
    source=[
        'migration_session_id.cpp',
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/base',
        '$BUILD_DIR/mongo/bson/util/bson_extract',
    ],
)

env.Library(
    target='sharding',
    source=[
        'migration_destination_manager.cpp',
        'migration_impl.cpp',
        'migration_source_manager.cpp',
        'sharded_connection_info.cpp',
        'sharding_state.cpp',
        'sharding_state_recovery.cpp',
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/base',
        '$BUILD_DIR/mongo/bson/util/bson_extract',
        '$BUILD_DIR/mongo/db/common',
        '$BUILD_DIR/mongo/s/sharding_initialization',
        'migration_types',
    ],
    LIBDEPS_TAGS=[
        # Depends on symbols defined in files in serverOnlyFiles, and has
        # many other missing dependencies.
        'incomplete',
    ],
)

env.Library(
    target='commands',
    source=[
        'merge_chunks_command.cpp',
        'move_chunk_command.cpp',
        'set_shard_version_command.cpp',
    ],
    LIBDEPS=[
        '$BUILD_DIR/mongo/db/repl/repl_coordinator_global',
        '$BUILD_DIR/mongo/s/serveronly',
        'metadata',
        'sharding',
    ],
    LIBDEPS_TAGS=[
        # Depends on getDeleter, defined in s/serveronly, which would be circular.
        'incomplete',
    ],
)

env.CppUnitTest(
    target='migration_types_test',
    source=[
        'migration_session_id_test.cpp',
    ],
    LIBDEPS=[
        'migration_types',
    ]
)

env.CppUnitTest(
    target='metadata_test',
    source=[
        'metadata_loader_test.cpp',
        'collection_metadata_test.cpp',
    ],
    LIBDEPS=[
        'metadata',
        '$BUILD_DIR/mongo/db/auth/authorization_manager_mock_init',
        '$BUILD_DIR/mongo/db/common',
        '$BUILD_DIR/mongo/dbtests/mocklib',
        '$BUILD_DIR/mongo/s/catalog/legacy/catalog_manager_legacy',
        '$BUILD_DIR/mongo/s/coreshard',
        '$BUILD_DIR/mongo/s/mongoscore',
    ]
)
